const router = require('koa-router')()
const mywechatapi = require('../../models/wechatapi/index.js')

router.prefix('/wechatapi')

router.get('/getnews', async (ctx, next) => {
    let type = ctx.query.type || "news";
    let offset = ctx.query.offset || 0;
    let count = ctx.query.count || 20;
    try {
        var data = await mywechatapi.getMaterial(type, offset, count);
        ctx.body = { "error": false, "result": data };
    } catch (err) {
        ctx.body = { "error": true, "message": "获取素材列表时出错：" + err.message }
    }
})

module.exports = router 